package com.xiyou.week06.dp;

/**
 * 70. 爬楼梯
 *
 * @ClassName：ClimbStairs
 * @Author：西柚
 * @Date：2022/2/25 10:17 上午
 * @Versiion：1.0
 */
public class ClimbStairs {

    /**
     * @param n
     * @return
     */
    public int climbStairs(int n) {
        if (n <= 2) {
            return n;
        }
        int i1 = 1;
        int i2 = 2;
        for (int i = 3; i <= n; i++) {
            int temp = i1 + i2;
            i1 = i2;
            i2 = temp;
        }
        return i2;
    }


    public static void main(String[] args) {
        ClimbStairs climbStairs = new ClimbStairs();
        System.out.println(climbStairs.climbStairs(10));
    }

}
